package org.nyt.medicalstore.service.impl;

import org.nyt.medicalstore.model.Symptom;
import org.nyt.medicalstore.repository.SymptomRepository;
import org.nyt.medicalstore.service.SymptomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class SymptomServiceImpl implements SymptomService {
    @Autowired
    private SymptomRepository symptomRepository;

    @Override
    public Symptom saveSymptom(Symptom symptom) {
        return symptomRepository.save(symptom);
    }

    @Override
    public Symptom getSymptomById(Long id) {
        Optional<Symptom> symptom = symptomRepository.findById(id);
        return symptom.orElse(null);
    }

    @Override
    public void deleteSymptom(Long id) {
        symptomRepository.deleteById(id);
    }
}
